home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / GUI / Dancing Finder Windows next >
Encoding:
Text File  |  1999-03-04  |  972 b   |  36 lines  |  [TEXT/ToyS]

  1. property kasJumpSize : 6 -- Should be even
  2.  
  3.  
  4. on run
  5.     idle
  6. end run
  7.  
  8. on idle
  9.     tell application "Finder"
  10.         set woze to the open windows
  11.         set pops to the name of every window whose popup is true
  12.     end tell
  13.     
  14.     set v to kasJumpSize div 2
  15.     set j to kasJumpSize
  16.     
  17.     repeat with w in woze
  18.         if (not (the same data is in w as in "Desktop")) then -- Don't dance the Desktop…
  19.             if the number of items in (collect items of woze that match w) is 1 then -- Only if unique name 
  20.                 if the number of items in (collect items of pops that match w) is 0 then -- And not a pop-up
  21.                     try
  22.                         tell application "Finder" to set wBox to reposition window w
  23.                         set dX to v - (random number from 0 to j)
  24.                         set dY to v - (random number from 0 to j)
  25.                         set wLoc to {(item 1 of wBox) + dX, (item 2 of wBox) + dY}
  26.                         tell application "Finder" to reposition window w to wLoc
  27.                     on error -- window was closed?
  28.                     end try
  29.                 end if
  30.             end if
  31.         end if
  32.     end repeat
  33.     
  34.     return 2
  35. end idle
  36.